<template>
	<view class="in_list">
		<navitop>
			<i class="iconfont icon-jiantou-copy" slot="left-slot" @click="outlot"></i>
			<span slot="center-slot">详情</span>
			<i class="iconfont icon-youcecaidan" slot="right-slot" v-show="qp_alert" @click="laert(data)"></i>
		</navitop>
		<div >
			<div :style="'margin-top:' + nv_height"></div>
			<scroll-view class="staff_b" scroll-y="true" touch-action=none; >
				<div class="public_list_out" >
						<div>
							<div>
								<div class="public_list" v-for="(rows,ind) in runData.tal" v-if="runData[rows.code]">
									<div class="public_list_left_one">
										{{rows.name}} : 
									</div>
									<div class="public_list_right" v-if="rows.code == 'createUserId'">
										{{runData['createUserName']}}
									</div>
									<div class="public_list_right" v-else-if="rows.code == 'updateUserId'">
										{{runData['updateUserName']}}
									</div>
									<div class="public_list_right" v-else>
										{{runData[rows.code]}}
									</div>
								</div>
							</div>
						</div>
						<div class="list_tree">
							<div style="padding: 0 0 20rpx 30rpx; border-bottom: 1px solid #cacaca; width: 100%;">
								销售阶段
							</div>
							<setp style="padding: 0 0 0 30rpx;" :options="list" direction="column" :active="activety" @NuberList="NuberList"></setp>
						</div>
				</div>
				
			</scroll-view>
			
		</div>
		<chunLeiPopups v-model="value" :popData="data" @tapPopup="tapPopup" :x="345" :y="95" placement="top-end"></chunLeiPopups>
		<popus ref="inbuseref">
			<div :style="alertWidth">
				<inbuseedit :rundataSorce="rundataSorce" @close="close"></inbuseedit>
			</div>
		</popus>
		
	</view>
</template>
<script>
import navitop from '@/components/common/navi-top'
import chunLeiPopups from "@/components/chunLei-popups/chunLei-popups"
import setp from '@/uni_modules/uni-steps/components/uni-steps/uni-steps'
import inbuseedit from '@/pages/common/index/subpage/inbusiness/inbusedit' // 修改组件
import popus from '@/uni_modules/uni-popup/components/uni-popup/uni-popup'
import {disable,getUserInfo} from '@/common/api/job/jobapi.js'	
export default {
	components: {
		setp,
		navitop,
		chunLeiPopups,
		inbuseedit,
		popus
	},
	props:{
		runData: {
			default: ''
		},
		crmType: {
			default: ''
		},
		setUrl:{
			default: ''
		}
	},
	data(){
		return {
			list:[
				{title: '事件一',index:0},
				{title: '事件二',index:1}, 
				{title: '事件三',index:2}, 
				{title: '事件四',index:3},
			
			],
			activety: 0,
			window_height: '',
			value: false,
			data: [],
			alertWidth:'',
			rundataSorce: [],
			qp_alert: true,
			nv_height:''
		}
	},
	mounted() {
		console.log('**********-----',this.setUrl)
		let _this = this;
		let arrYn = [];
		
		this.nv_height = uni.getSystemInfoSync().statusBarHeight + 55 + 'px';
		
		uni.getSystemInfo({
		    success: function (res) {
				_this.alertWidth = 'width:' + res.windowWidth + 'px;'
		    }
		});
		
		
		const res = uni.getSystemInfoSync();
		this.window_height = 'height:' + res.windowHeight + 'px;';
		
		this.runData.tal.forEach(item => {
			if(item.code == 'saleStage'){
				for(let i in item.val.split(',')){
					arrYn.push({title: item.val.split(',')[i],index: i})
				}
			}
		})
		this.list = arrYn;
		
		
		this.list.forEach(item => {
			if(this.runData.saleStage == item.title){
				this.activety = Number(item.index)
			}
		})
		this.qp_list(this.crmType);
		console.log(this.runData)
		
	},
	methods: {
		
		// 显示气泡列表  + 权限控制
		qp_list(val){
			if(val == 0){	// 公海
				let spto = [
					{title:"编辑",code:2,icon: 'icon-bianji',msg_code: 'crm:clue:business:edit' },
					{title:"删除",code:3,icon: 'icon-shanchu',msg_code: 'crm:clue:business:disable' },
				];
				this.get_userInfo(spto);
			}
			if(val == 1){	// 潜在
				let spto = [
					{title:"编辑",code:2,icon: 'icon-bianji',msg_code: 'crm:potential:business:edit' },
					{title:"删除",code:3,icon: 'icon-shanchu',msg_code: 'crm:potential:business:disable' },
				];
				this.get_userInfo(spto);
			}
			if(val == 2){	// 成交
				let spto = [
					{title:"编辑",code:2,icon: 'icon-bianji',msg_code: 'crm:deals:business:edit' },
					{title:"删除",code:3,icon: 'icon-shanchu',msg_code: 'crm:deal:business:disable' },
				];
				this.get_userInfo(spto);
			}
		},
		
		// 权限控制
		get_userInfo(spto){
			let sotrt = [];
			getUserInfo().then((rows) => {
				if(rows.code == 200) {
					rows.data.permissions.forEach(item => {
						spto.forEach(vals =>{
							if(item == vals.msg_code){
								sotrt.push(vals);
							}
						})
					})
				}
				if(sotrt == 0){
					this.qp_alert = false;
				}else {
					this.qp_alert = true;
				}
				this.data = sotrt;
			})
		},
		
		
		// 获取流程组件进度
		NuberList(val){
			this.activety =Number(val.index);
		},
		// 返回
		outlot(){
			this.$emit('close',2)
		},
		// 气泡弹窗
		laert(val){
			this.value = true;
		},
		tapPopup(val){
			let _this = this;
			if(val.code == 2){ // 编辑
				uni.navigateTo({
					url: '/pages/common/index/subpage/business/obj/businessedit?id=' + this.runData.id + this.setUrl
				})
			}
			if(val.code == 3) {	// 删除
				uni.showModal({
					title: '提示',
					content:'确定要删除吗？',
					success: function(res){
						if(res.confirm){
							disable([_this.runData.id]).then((rows) =>{
								if(rows.code == 200){
									uni.showToast({
										title: '删除成功'
									});
									setTimeout(()=>{
										_this.$emit('close',1)
									},1500)
								}
							})
						}else{
							console.log(1)
						}
						
					}
					})
				
				
			}
		},
		close(val){
			if(val == 1){
				this.$refs.inbuseref.close();
				location.reload();
			}else{
				this.$refs.inbuseref.close();
			}
		}
		
		
	}
}	
	
	
</script>

<style scoped lang="scss">
.in_list {
	width: 100%;
	height: 100%;
	background-color: #fff;
			
}
.list_tree {
			padding: 60rpx 0 0 0;
			width: 60%;
		}
		.staff_b {
			height: 800px;
		}
	
</style>
